# -*- coding: UTF-8 -*-
import pika

def publish(info):
    credentials=pika.PlainCredentials('yanghui', 'yanghui')
    connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost', credentials=credentials))
    channel = connection.channel()
    channel.queue_declare(queue='hello', durable=True)
    channel.queue_bind(exchange='exchange',
                   queue="hello",
                   routing_key='sina')
    channel.basic_publish(exchange='exchange',
                      routing_key="sina",
                      body=info)
    print(" [x] Sent 'Hello World!'")
    connection.close()


